<?php

namespace App\Console\Commands\WorkOrder;

use App\Enums\WorkOrder\OrderEnum;
use App\Models\WorkOrder\WorkOrderApplyMainModel;
use App\Models\WorkOrder\WorkOrderApplyManagerModel;
use App\Models\WorkOrder\WorkOrderMissionModel;
use App\Models\WorkOrder\WorkOrderRejectDetailModel;
use App\Models\WorkOrder\WorkOrderRejectModel;
use App\Service\WorkOrder\Manager\ManagerService;
use App\Service\WorkOrder\Mission\MissionEngineService;
use Illuminate\Console\Command;

class DelOrder extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'workOrder:del-order {workOrderNo}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '删除工单';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $workOrderNo = $this->argument('workOrderNo');
        if (!$workOrderNo) {
            dd('workOrderNo不能为空');
        }

        $workOrderNos = [$workOrderNo];

        dump($workOrderNos);
        $this->ask('请确认以上订单号');

        // main
        WorkOrderApplyMainModel::query()->whereIn('workOrderNo', $workOrderNos)->update(['isDeleted' => 1]);

        // manager
        WorkOrderApplyManagerModel::query()->whereIn('workOrderNo', $workOrderNos)->update(['isDeleted' => 1]);

        // mission
        WorkOrderMissionModel::query()->whereIn('workOrderNo', $workOrderNos)->update(['isDeleted' => 1]);

        // reject
        WorkOrderRejectModel::query()->whereIn('workOrderNo', $workOrderNos)->update(['isDeleted' => 1]);

        // reject_details
        WorkOrderRejectDetailModel::query()->whereIn('workOrderNo', $workOrderNos)->update(['isDeleted' => 1]);
    }
}
